#!/usr/bin/env python

import sys

potato1 = """<img src='http://images.neopets.com/medieval/potato1"""
potato2 = """<img src='http://images.neopets.com/medieval/potato2"""
potato3 = """<img src='http://images.neopets.com/medieval/potato3"""
potato4 = """<img src='http://images.neopets.com/medieval/potato4"""

def countPotatoes(html):
  total = 0
  for line in html:
    if '<table align=center cellpadding=3 cellspacing=0 border=0><tr' in line:
      total+= line.count(potato1)
      total+= line.count(potato2)
      total+= line.count(potato3)
      total+= line.count(potato4)
      break
  return total


responseCurl = 'http://www.neopets.com/medieval/potatocounter.phtml?guess=%s' % (str(total))
#print responseCurl
#response = urllib.urlopen( responseCurl ).read()
#with open('guess.txt') as f:
#  response = f.read()
#print len(response)
#print response.split('<b>Potato ')[1].split('table')[0]


if __name__ == '__main__':
  with open(sys.argv[1]) as f:
    html = f.readlines()
  print countPotatoes(html)

